chore(tests): consolidate test patterns — shared Vitest base, central @sim/testing mocks, check:test-patterns, lean agent docs - #8309
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
There was a problem hiding this comment.
1 issue found across 2296 files
Confidence score: 5/5
- In
packages/testing/src/mocks/billing-core.mock.ts, duplicated pricing logic could drift frombilling-subscription-utils.mock.tsas pricing changes; reuse a shared implementation to keep the mocks aligned.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/testing/src/mocks/billing-core.mock.ts">
<violation number="1" location="packages/testing/src/mocks/billing-core.mock.ts:4">
P3: This pricing implementation duplicates the existing centralized `billing-subscription-utils.mock.ts` helper, so future pricing changes can make the two mocks disagree. Reuse one shared implementation or extract the pure pricing helper instead of maintaining both copies.</violation>
</file>
Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
… @sim/testing mocks, check:test-patterns, lean agent docs
… the async-import form
…mentation rules and small doc pointers
3dd94af to
0feb98a
Compare
Summary
vitest.shared.ts): every workspace config extends it;clearMocks,restoreMocks,unstubEnvs,unstubGlobalsare on (integration mode keeps per-file fixtures),globals: trueremoved. ~450 redundantvi.clearAllMocks/restoreAllMocks/unstubAll*hook calls deleted@sim/testingis now the single home for mocks: ~220 central mocks (xMock+xMockFns, full export surface, faithful enums/error classes) and shared helpers (jsonResponse,createRouteContext,createDeferred,flushMicrotasks,collectStream, principal factories). ~2,300 hand-rolledvi.mockfactories and ~600 inline principals across ~1,900 test files now use them@sim/dbre-exports every schema table,@trigger.dev/sdktask()returns its config (+runs.*,idempotencyKeys,AbortTaskRunError), drizzlesqlis a spy,getMockLogger(name), stable telemetry spies.schemaMocktable names are generated frompackages/db/schema.ts(check:schema-mockguards drift)check:test-patternsaudit (incheck:audits): fails on a new local factory for a centrally mocked module, a re-mock of a global module, a local copy of a shared helper, a redundant hook, or a__tests__/dir. Ratchet baseline holds the 145 deliberate exceptions (per-test component stand-ins, real-SQL inspection, …)__tests__//tests/dirs colocated, 26 topic-split files merged into their source's testTEST_DATABASE_URL/TEST_REDIS_URLcontract (IPv6 loopback works, credentialed Redis rejected); the OAuth token integration test no longer leaves a rate-limit bucket behindcondition-handlerfixtures, restored MCP same-author secret-retention case, shared DB guard; declined theclearMocks-off claims (Vitest 5 default, now explicit in config) and the DB-name/test-rule suggestionsglobal.mdfolded in, API rules in onesim-api-contracts.md,apps/sim/AGENTS.md→ pointer, contradictions fixed (comments, hooks example, emcn paths, canvas sentences, repo tree).sim-testing.md365 → 165 lines (mock table → discovery rule). One run command everywhere (bun run --cwd <ws> test);/shipand/cleanupgate tests throughtest-auditgenerate-docsno longer reads mock descriptions from test files into the integration catalog; path-independent secret-leak checks inknowledge-processing; best-of-three scaling ratio for the chat-content linearity checksType of Change
Testing
bun run test(every workspace): apps/sim 34,269 passed; only failure was a pre-existing sim-cli lock-timing flake that passes 3/3 alonebun run test:integration(Docker Postgres + Redis): apps/sim 96 files / 926 tests, packages/db 14 / 95 — all passbunx turbo run type-check26/26,bun run lint,bun run check:audits(51),docs-manifest:check, block registry,check:migrationsChecklist
test-auditauthoring gate)